<?php
if(!empty($_REQUEST['lang']))
{
    $lang = $_REQUEST['lang'];
    setcookie("lang", $lang, time()+3600*24*7);
}
if(empty($_COOKIE['lang']))
{
    setcookie("lang", "vi", time()+3600*24*7);
}

header("Location: " . $_SERVER['HTTP_REFERER']);